package com.my.drools;

import com.my.drools.entity.Account;
import com.my.drools.util.KnowledgeSessionHelper;
import com.my.drools.util.OutputDisplay;
import org.drools.core.common.DefaultAgenda;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.kie.api.event.rule.ObjectDeletedEvent;
import org.kie.api.event.rule.ObjectInsertedEvent;
import org.kie.api.event.rule.ObjectUpdatedEvent;
import org.kie.api.event.rule.RuleRuntimeEventListener;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.StatelessKieSession;
import org.kie.api.runtime.rule.FactHandle;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @Description
 * @Author maye
 * @Date 2019/7/18
 * @Version V1.0.0
 */
public class FirstTry {
    StatelessKieSession statelessKieSession = null;
    KieSession sessionStatefull = null;
    static KieContainer kieContainer;

    @BeforeClass
    public static void beforeClass() {

        kieContainer = KnowledgeSessionHelper.createRuleBase();
    }

    @Before
    public void setUp(){
        Logger.getLogger(FirstTry.class.getName()).setLevel(Level.OFF);
        System.out.println("------------Before------------");
    }

    @After
    public void tearDown() {
        System.out.println("------------After------------");
    }

    @Test
    public void testFirstOne() {
        sessionStatefull = KnowledgeSessionHelper.getStateFulknowledgeSession(
                kieContainer, "ksession-lesson1");
        sessionStatefull.fireAllRules();
    }

}